package br.com.cfccultura.admin.model.enums;

import java.util.Calendar;
import java.util.Date;

public enum DiaSemana {
	
	DOMINGO(1),
	SEGUNDA(2),
	TERCA(3),
	QUARTA(4),
	QUINTA(5),
	SEXTA(6),
	SABADO(7);
	
	private Integer value;
	
	DiaSemana(Integer value) {
		this.value = value;
	}
	
	public Integer getValue() {
		return value;
	}
	
	public static DiaSemana setValue(Integer value) {
		switch(value) {
			case 1: return DOMINGO;
			case 2: return SEGUNDA;
			case 3: return TERCA;
			case 4: return QUARTA;
			case 5: return QUINTA;
			case 6: return SEXTA;
			case 7: return SABADO;
		}
		throw new RuntimeException("Invalid DiaSemana -> " + value);
	}
	
	public static DiaSemana setValue(Date data) {
		Calendar c = Calendar.getInstance();
		c.setTime(data);
		
		return setValue(c.get(Calendar.DAY_OF_WEEK));
	}
	
	public Boolean isFinalSemana() {
		if(getValue() == 1 || getValue() == 7)
			return true;
		return false;
	}
}
